<?php
class PNAjaxCarPropertyArray extends PNObjectExArray {
  function PNAjaxCarPropertyArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'innoforum_carproperty';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';

    $this->_init($init, $where);
  }

  function genSort(){
    return " ORDER BY pro_name ASC";
  }

  function genFilter(){
    $category_id    = FormUtil::getPassedValue ('category_id', false);
    $subcategory_id = FormUtil::getPassedValue ('subcategory_id', false);
    $brand_id       = FormUtil::getPassedValue ('brand_id', false);
    $model_id       = FormUtil::getPassedValue ('model_id', false);

    $wheres = array();

    //filter by selector
    if ($category_id && intval($category_id)) $wheres[] = "pro_category_id ='$category_id'";
    if ($subcategory_id && intval($brand_id)) $wheres[] = "pro_subcategory_id ='$subcategory_id'";
    if ($brand_id && intval($brand_id)) $wheres[] = "pro_brand_id ='$brand_id'";
    if ($model_id && intval($brand_id)) $wheres[] = "pro_model_id ='$model_id'";
    //var_dump($wheres);
    return implode(' AND ', $wheres) ;
  }

}

